<%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean" prefix="bean" %>

<script language="javascript">
function addRow(tableID) {

			var table = document.getElementById(tableID);

			var rowCount = table.rows.length;
			var row = table.insertRow(rowCount);

			var cell1 = row.insertCell(0);
			var element1 = document.createElement("input");
			element1.type = "checkbox";
			cell1.appendChild(element1);

			var cell2 = row.insertCell(1);
			cell2.innerHTML = '<table><tr><td>Branch name:</td><td><INPUT name="branchName" type="text" /></td></tr><tr><td>Address:</td><td><INPUT name="address" type="text" /></td></tr><tr><td>Phone:</td><td><INPUT name="phone" type="text" /></td></tr><tr><td>Email:</td><td><INPUT name="email" type="text" /></td></tr></table>';
			
			
		}

		function deleteRow(tableID) {
			try {
			var table = document.getElementById(tableID);
			var rowCount = table.rows.length;

			for(var i=0; i<rowCount; i++) {
				var row = table.rows[i];
				var chkbox = row.cells[0].childNodes[0];
				if(null != chkbox && true == chkbox.checked && table.rows.length!=1) {
					table.deleteRow(i);
					rowCount--;
					i--;
				}

			}
			}catch(e) {
				alert(e);
			}
		}
</script>

<div class="tabber">
<div class="tabbertab">
<h4>Add a registered company account</h4>
	<table>	
	
    <html:form action="/addcompany">
    <tr>
    <td>Company name:</td><td><html:text property="companyName" style=" width : 148px;"/></td>
    </tr>
    <tr>
    <td>Website:</td><td><html:text property="companyWebsite" style=" width : 148px;"/></td>
    </tr>
    
    <tr>
    <td>Field:</td>
    <td><html:select property="selectedFields" style=" width : 148px;" multiple="">
    <html:optionsCollection property="companyFields" label="fieldName" value="fieldId"/>
    </html:select>
    </td>
    </tr>
    <tr><td></td><td>Press and hold ctrl key to select more than one field</td></tr>
    
    <tr>
    <td>Company Account:</td>
    <td>
    <br/>
    <br/>
    <br/>
    <table>
    <tr>
    <td>User name:</td>
    <td><html:text property="userName" /></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><html:password property="password" /></td>
    </tr>
    </table>
    </td>
    </tr>
    
    <tr><td>Contact details:</td>
    <td> <INPUT type="button" value="Add contact details" onclick="addRow('dataTable')"  />
    <INPUT type="button" value="Delete contact details" onclick="deleteRow('dataTable')"  /> 
    <TABLE id="dataTable" width="350px">
	        <TR>
	            <TD><INPUT type="checkbox" name="chk"/></TD>
	            <TD>
	            <table>
	            <tr><td>Branch name:</td><td><INPUT name="branchName" type="text" /></td></tr>
	            <tr><td>Address:</td><td><INPUT name="address" type="text" /></td></tr>
	            <tr><td>Phone:</td><td><INPUT name="phone" type="text" /></td></tr>
	            <tr><td>Email:</td><td><INPUT name="email" type="text" /></td></tr>
	            </table>
	            </TD>
	           
	        </TR>	 </TABLE>  	
    
	</td>
    </tr>
    
    <tr><td></td><td><html:submit value="Add company"/></td></tr>

</html:form> 
   
</table>
</div>

<div class="tabbertab">
<h4 class="tabbertab">Deactivate a registered company account</h4>
<table>


<html:form action="deactivatecompany">
<tr>
<td>
Select a company:
</td>
<td>
<html:select property="selectedCompany">
	<html:optionsCollection property="registeredCompanies" label="CName" value="CId"/>
</html:select>
</td>
</tr>
<tr>
<td></td>
<td>
<html:submit value="Deactivate"/>
</td>
</tr>
	

</html:form>
</table>
</div>
</div>
